const multer = require('koa-multer');//上传图片的第三方库
const path = require('path')
//配置storage  
var uploadImg_storage = multer.diskStorage({//存储方法
    //文件保存路径
    destination: function (req, file, cb) {
        cb(null, path.join(__dirname ,'../public/uploadImgs')) //路径一定要对
    },
    //修改文件名称
    filename: function (req, file, cb) {
        var fileFormat = (file.originalname).split(".");
        cb(null,Date.now() + "." + fileFormat[fileFormat.length - 1]);
    },
})
//文件上传限制
    const uploadImg_limits = {
        fields: 10,//非文件字段的数量
        fileSize:12 * 500 * 1024,//单位 b
        files: 1//文件数量
    }
//加载配置
var uploadimg = multer({ storage: uploadImg_storage , uploadImg_limits})

module.exports = {uploadimg}